Required Libraries¶

In [ ]:
import yfinance as yf
import pandas as pd
from datetime import datetime
from arch import arch_model
import matplotlib.pyplot as plt
import numpy as np
import warnings 
warnings.filterwarnings("ignore")

Question 1¶

In [ ]:
start_date = "2022-08-30"
end_date = "2024-09-30"
In [ ]:
exchange_tickers = ["ZAR=X", "AUDUSD=X", "GBPUSD=X"]
exchange_data = {ticker: yf.download(ticker, start=start_date, end=end_date) for ticker in exchange_tickers}
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
In [ ]:
for ticker, data in exchange_data.items():
    print(f"Data for {ticker}")
    print(data.head())
Data for ZAR=X
                 Open       High        Low      Close  Adj Close  Volume
Date                                                                     
2022-08-30  16.809641  16.972799  16.745100  16.809641  16.809641       0
2022-08-31  16.957800  17.087179  16.858629  16.957800  16.957800       0
2022-09-01  17.105209  17.304930  17.088301  17.105209  17.105209       0
2022-09-02  17.251900  17.345699  17.172701  17.251900  17.251900       0
2022-09-05  17.300900  17.418039  17.146500  17.300900  17.300900       0
Data for AUDUSD=X
                Open      High       Low     Close  Adj Close  Volume
Date                                                                 
2022-08-30  0.690751  0.695797  0.685990  0.690751   0.690751       0
2022-08-31  0.685740  0.690422  0.684340  0.685740   0.685740       0
2022-09-01  0.682850  0.684360  0.677172  0.682850   0.682850       0
2022-09-02  0.679530  0.685380  0.678109  0.679530   0.679530       0
2022-09-05  0.679030  0.680411  0.677360  0.679030   0.679030       0
Data for GBPUSD=X
                Open      High       Low     Close  Adj Close  Volume
Date                                                                 
2022-08-30  1.172127  1.175807  1.162304  1.172251   1.172251       0
2022-08-31  1.166086  1.169454  1.160025  1.165977   1.165977       0
2022-09-01  1.159689  1.161710  1.150324  1.159851   1.159851       0
2022-09-02  1.154734  1.158856  1.153136  1.154894   1.154894       0
2022-09-05  1.147855  1.152074  1.144518  1.147460   1.147460       0
In [ ]:
def calculate_returns(df):
    df['Returns'] = df['Adj Close'].pct_change().dropna() * 100
    return df['Returns'].dropna()
In [ ]:
def fit_garch_model(returns, model_type='GARCH'):
    if model_type == 'ARCH':
        model = arch_model(returns, vol='Arch', p=1)
    elif model_type == 'GARCH':
        model = arch_model(returns, vol='Garch', p=1, q=1)
    elif model_type == 'EGARCH':
        model = arch_model(returns, vol='EGarch', p=1, q=1)
    elif model_type == 'TGARCH':
        model = arch_model(returns, vol='Garch', p=1, o=1, q=1)
    elif model_type == 'PGARCH':
        model = arch_model(returns, p=1, q=1, o=1, power=1.0)
    else:
        raise ValueError(f"Unsupport model type: {model_type}")
    
    model_fit = model.fit(disp='off')
    return model_fit
In [ ]:
def visualize_results(returns, model_results, title):

    # plot returns
    plt.figure(figsize=(20, 10))
    plt.subplot(2, 1, 1)
    plt.plot(returns, label='Returns', color='blue')
    plt.title(f"Daily Returns for {title}", fontsize=20, fontweight='bold')
    plt.xlabel('Date')
    plt.ylabel('Returns')
    plt.legend()

    # plot volatility
    plt.subplot(2, 1, 2)
    plt.plot(model_results.conditional_volatility, label='Conditional Volatility', color='red')
    plt.title(f"Conditional Volatility for {title}", fontsize=20, fontweight='bold')
    plt.xlabel('Date')
    plt.ylabel('Volatility')
    plt.legend()
    plt.tight_layout()
    plt.show()
In [ ]:
def compare_volatility_forecasting(returns, models):

    realized_volatility = returns**2
    forecast_errors = {}

    for model_name, model_results in models.items():
        forecasted_volatility = model_results.conditional_volatility

        mse = np.mean((realized_volatility - forecasted_volatility**2)**2)

        forecast_errors[model_name] = mse

        print(f"{model_name} - Volatility Forecasting MSE: {mse}")

    best_model = min(forecast_errors, key=forecast_errors.get)
    
    return best_model
In [ ]:
def evaluate_and_visualize_models(returns, key):
    print(f"\n**********************************************************Processing {key}*****************************************************************")

    models = {}

    # ARCH
    print("Fitting ARCH(1) model...")
    arch_res = fit_garch_model(returns, model_type='ARCH')
    models['ARCH'] = arch_res
    print(arch_res.summary())
    visualize_results(returns, arch_res, f"{key} ARCH(1)")

    # GARCH
    print("Fitting GARCH(1,1) model...")
    garch_res = fit_garch_model(returns, model_type='GARCH')
    models['GARCH'] = garch_res
    print(garch_res.summary())
    visualize_results(returns, garch_res, f"{key} GARCH(1,1)")

    # EGARCH
    print("Fitting EGARCH(1,1) model...")
    egarch_res = fit_garch_model(returns, model_type='EGARCH')
    models['EGARCH'] = egarch_res
    print(egarch_res.summary())
    visualize_results(returns, egarch_res, f"{key} EGARCH(1,1)")

    # TGARCH
    print("Fitting TGARCH(1,1) model...")
    tgarch_res = fit_garch_model(returns, model_type='TGARCH')
    models['TGARCH'] = tgarch_res
    print(tgarch_res.summary())
    visualize_results(returns, tgarch_res, f"{key} TGARCH(1,1)")

    # PGARCH
    print("Fitting PGARCH(1,1) model...")
    pgarch_res = fit_garch_model(returns, model_type='PGARCH')
    models['PGARCH'] = pgarch_res
    print(pgarch_res.summary())
    visualize_results(returns, pgarch_res, f"{key} PGARCH(1,1)")

    # Compare AIC and BIC
    print("\nModel Comparisons:")
    print(f"ARCH AIC: {arch_res.aic}, BIC: {arch_res.bic}")
    print(f"GARCH AIC: {garch_res.aic}, BIC: {garch_res.bic}")
    print(f"EGARCH AIC: {egarch_res.aic}, BIC: {egarch_res.bic}")
    print(f"TGARCH AIC: {tgarch_res.aic}, BIC: {tgarch_res.bic}")
    print(f"PGARCH AIC: {pgarch_res.aic}, BIC: {pgarch_res.bic}")

    best_bic = min(arch_res.bic, garch_res.bic, egarch_res.bic, tgarch_res.bic, pgarch_res.bic)
    if best_bic == arch_res.bic:
        print("\nBest model based on BIC: ARCH")
    elif best_bic == garch_res.bic:
        print("\nBest model based on BIC: GARCH")
    elif best_bic == egarch_res.bic:
        print("\nBest model based on BIC: EGARCH")
    elif best_bic == pgarch_res.bic:
        print("\nBest model based on BIC: PGARCH")
    else:
        print("\nBest model based on BIC: TGARCH")

    # Compare models based on volatility forecasting
    print("\nComparing models based on volatility forecasting...")
    best_forecast_model = compare_volatility_forecasting(returns, models)
    print(f"\nBest model based on volatility forecasting (lowest mse): {best_forecast_model}")
In [ ]:
for key, df in exchange_data.items():
    returns = calculate_returns(df)
    evaluate_and_visualize_models(returns, key)
**********************************************************Processing ZAR=X*****************************************************************
Fitting ARCH(1) model...
                      Constant Mean - ARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                       ARCH   Log-Likelihood:               -679.737
Distribution:                  Normal   AIC:                           1365.47
Method:            Maximum Likelihood   BIC:                           1378.28
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:39   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu             0.0134  3.825e-02      0.351      0.726 [-6.157e-02,8.839e-02]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.7374  6.009e-02     12.273  1.270e-34    [  0.620,  0.855]
alpha[1]       0.0421  4.723e-02      0.892      0.373 [-5.046e-02,  0.135]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting GARCH(1,1) model...
                     Constant Mean - GARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                      GARCH   Log-Likelihood:               -676.275
Distribution:                  Normal   AIC:                           1360.55
Method:            Maximum Likelihood   BIC:                           1377.63
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:39   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu             0.0111  3.791e-02      0.292      0.770 [-6.322e-02,8.539e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      2.3413e-07  2.277e-03  1.028e-04      1.000 [-4.462e-03,4.462e-03]
alpha[1]   8.0898e-07  3.189e-03  2.537e-04      1.000 [-6.249e-03,6.251e-03]
beta[1]        0.9993  1.678e-03    595.342      0.000      [  0.996,  1.003]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting EGARCH(1,1) model...
                     Constant Mean - EGARCH Model Results                     
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                     EGARCH   Log-Likelihood:               -670.801
Distribution:                  Normal   AIC:                           1349.60
Method:            Maximum Likelihood   BIC:                           1366.68
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:40   Df Model:                            1
                                 Mean Model                                 
============================================================================
                 coef    std err          t      P>|t|      95.0% Conf. Int.
----------------------------------------------------------------------------
mu             0.0149  1.210e-08  1.231e+06      0.000 [1.489e-02,1.489e-02]
                               Volatility Model                               
==============================================================================
                 coef    std err          t      P>|t|        95.0% Conf. Int.
------------------------------------------------------------------------------
omega      6.6501e-04  3.632e-12  1.831e+08      0.000   [6.650e-04,6.650e-04]
alpha[1]      -0.0466  9.617e-09 -4.849e+06      0.000 [-4.664e-02,-4.664e-02]
beta[1]        0.9979  5.895e-10  1.693e+09      0.000       [  0.998,  0.998]
==============================================================================

Covariance estimator: robust
WARNING: The optimizer did not indicate successful convergence. The message was Iteration limit reached.
See convergence_flag.

c:\Users\Alli Ajagbe\AppData\Local\Programs\Python\Python311\Lib\site-packages\arch\univariate\base.py:766: ConvergenceWarning: The optimizer returned code 9. The message is:
Iteration limit reached
See scipy.optimize.fmin_slsqp for code meaning.

  warnings.warn(
No description has been provided for this image
Fitting TGARCH(1,1) model...
                   Constant Mean - GJR-GARCH Model Results                    
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                  GJR-GARCH   Log-Likelihood:               -676.178
Distribution:                  Normal   AIC:                           1362.36
Method:            Maximum Likelihood   BIC:                           1383.70
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:40   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu         6.0180e-03  4.211e-02      0.143      0.886 [-7.652e-02,8.856e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      7.4023e-07  2.767e-03  2.675e-04      1.000 [-5.423e-03,5.424e-03]
alpha[1]   2.9164e-07  1.359e-02  2.147e-05      1.000 [-2.663e-02,2.663e-02]
gamma[1]   6.3935e-03  2.559e-02      0.250      0.803 [-4.376e-02,5.655e-02]
beta[1]        0.9960  4.780e-03    208.361      0.000      [  0.987,  1.005]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting PGARCH(1,1) model...
                  Constant Mean - TARCH/ZARCH Model Results                   
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                TARCH/ZARCH   Log-Likelihood:               -678.950
Distribution:                  Normal   AIC:                           1367.90
Method:            Maximum Likelihood   BIC:                           1389.25
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:41   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu             0.0138  3.877e-02      0.357      0.721 [-6.216e-02,8.983e-02]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.4107      0.169      2.426  1.528e-02  [7.883e-02,  0.742]
alpha[1]       0.0789  4.821e-02      1.638      0.101 [-1.553e-02,  0.173]
gamma[1]      -0.0350  5.830e-02     -0.600      0.549  [ -0.149,7.931e-02]
beta[1]        0.4822      0.193      2.494  1.264e-02    [  0.103,  0.861]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Model Comparisons:
ARCH AIC: 1365.4739414081632, BIC: 1378.281230259282
GARCH AIC: 1360.5508589318451, BIC: 1377.6272440666703
EGARCH AIC: 1349.6025407396355, BIC: 1366.6789258744607
TGARCH AIC: 1362.3556485727302, BIC: 1383.7011299912615
PGARCH AIC: 1367.9000905762286, BIC: 1389.24557199476

Best model based on BIC: EGARCH

Comparing models based on volatility forecasting...
ARCH - Volatility Forecasting MSE: 1.1501724653014256
GARCH - Volatility Forecasting MSE: 1.1363881133247706
EGARCH - Volatility Forecasting MSE: 1.1138408425359607
TGARCH - Volatility Forecasting MSE: 1.135994053682568
PGARCH - Volatility Forecasting MSE: 1.1465230503358819

Best model based on volatility forecasting (lowest mse): EGARCH

**********************************************************Processing AUDUSD=X*****************************************************************
Fitting ARCH(1) model...
                      Constant Mean - ARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                       ARCH   Log-Likelihood:               -542.644
Distribution:                  Normal   AIC:                           1091.29
Method:            Maximum Likelihood   BIC:                           1104.10
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:41   Df Model:                            1
                                  Mean Model                                  
==============================================================================
                  coef    std err          t      P>|t|       95.0% Conf. Int.
------------------------------------------------------------------------------
mu         -3.5260e-03  2.996e-02     -0.118      0.906 [-6.224e-02,5.519e-02]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.4363  3.882e-02     11.237  2.673e-29    [  0.360,  0.512]
alpha[1]       0.0490  6.578e-02      0.744      0.457 [-7.996e-02,  0.178]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting GARCH(1,1) model...
                     Constant Mean - GARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                      GARCH   Log-Likelihood:               -518.640
Distribution:                  Normal   AIC:                           1045.28
Method:            Maximum Likelihood   BIC:                           1062.36
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:42   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu         6.1500e-04  2.703e-02  2.275e-02      0.982 [-5.237e-02,5.360e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      2.8021e-04  7.842e-04      0.357      0.721 [-1.257e-03,1.817e-03]
alpha[1]       0.0000  3.281e-03      0.000      1.000 [-6.431e-03,6.431e-03]
beta[1]        0.9969  4.602e-03    216.612      0.000      [  0.988,  1.006]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting EGARCH(1,1) model...
                     Constant Mean - EGARCH Model Results                     
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                     EGARCH   Log-Likelihood:               -516.859
Distribution:                  Normal   AIC:                           1041.72
Method:            Maximum Likelihood   BIC:                           1058.79
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:43   Df Model:                            1
                                  Mean Model                                  
==============================================================================
                  coef    std err          t      P>|t|       95.0% Conf. Int.
------------------------------------------------------------------------------
mu         -1.7269e-03  8.471e-03     -0.204      0.838 [-1.833e-02,1.488e-02]
                                Volatility Model                               
===============================================================================
                  coef    std err          t      P>|t|        95.0% Conf. Int.
-------------------------------------------------------------------------------
omega      -6.3099e-04  6.665e-10 -9.468e+05      0.000 [-6.310e-04,-6.310e-04]
alpha[1]       -0.0325  1.378e-05  -2359.576      0.000 [-3.253e-02,-3.248e-02]
beta[1]         1.0000  3.385e-11  2.954e+10      0.000       [  1.000,  1.000]
===============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting TGARCH(1,1) model...
                   Constant Mean - GJR-GARCH Model Results                    
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                  GJR-GARCH   Log-Likelihood:               -518.640
Distribution:                  Normal   AIC:                           1047.28
Method:            Maximum Likelihood   BIC:                           1068.63
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:43   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu         6.1404e-04  2.716e-02  2.261e-02      0.982 [-5.262e-02,5.385e-02]
                               Volatility Model                               
==============================================================================
                  coef    std err          t      P>|t|       95.0% Conf. Int.
------------------------------------------------------------------------------
omega       2.8007e-04  7.843e-04      0.357      0.721 [-1.257e-03,1.817e-03]
alpha[1]        0.0000  6.746e-03      0.000      1.000 [-1.322e-02,1.322e-02]
gamma[1]   -1.4614e-10  1.514e-02 -9.651e-09      1.000 [-2.968e-02,2.968e-02]
beta[1]         0.9969  4.811e-03    207.197      0.000      [  0.987,  1.006]
==============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting PGARCH(1,1) model...
                  Constant Mean - TARCH/ZARCH Model Results                   
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                TARCH/ZARCH   Log-Likelihood:               -522.817
Distribution:                  Normal   AIC:                           1055.63
Method:            Maximum Likelihood   BIC:                           1076.98
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:44   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu            -0.0120  2.747e-02     -0.437      0.662 [-6.584e-02,4.183e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      1.7088e-03  2.605e-03      0.656      0.512 [-3.396e-03,6.814e-03]
alpha[1]       0.0000  2.305e-02      0.000      1.000 [-4.518e-02,4.518e-02]
gamma[1]       0.0295  2.359e-02      1.252      0.211 [-1.671e-02,7.577e-02]
beta[1]        0.9852  1.326e-02     74.291      0.000      [  0.959,  1.011]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Model Comparisons:
ARCH AIC: 1091.2878891517414, BIC: 1104.0951780028602
GARCH AIC: 1045.2798563631154, BIC: 1062.3562414979406
EGARCH AIC: 1041.7182170275305, BIC: 1058.7946021623557
TGARCH AIC: 1047.2798566243118, BIC: 1068.6253380428432
PGARCH AIC: 1055.6334493925367, BIC: 1076.978930811068

Best model based on BIC: EGARCH

Comparing models based on volatility forecasting...
ARCH - Volatility Forecasting MSE: 0.6419641481631231
GARCH - Volatility Forecasting MSE: 0.6012366262752905
EGARCH - Volatility Forecasting MSE: 0.6013808781523678
TGARCH - Volatility Forecasting MSE: 0.6012364888996955
PGARCH - Volatility Forecasting MSE: 0.6077889091498082

Best model based on volatility forecasting (lowest mse): TGARCH

**********************************************************Processing GBPUSD=X*****************************************************************
Fitting ARCH(1) model...
                      Constant Mean - ARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                       ARCH   Log-Likelihood:               -461.819
Distribution:                  Normal   AIC:                           929.639
Method:            Maximum Likelihood   BIC:                           942.446
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:44   Df Model:                            1
                                  Mean Model                                  
==============================================================================
                  coef    std err          t      P>|t|       95.0% Conf. Int.
------------------------------------------------------------------------------
mu         -3.4596e-03  2.401e-02     -0.144      0.885 [-5.053e-02,4.361e-02]
                             Volatility Model                             
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
omega          0.2693  5.535e-02      4.865  1.147e-06   [  0.161,  0.378]
alpha[1]       0.2765      0.125      2.217  2.662e-02 [3.207e-02,  0.521]
==========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting GARCH(1,1) model...
                     Constant Mean - GARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                      GARCH   Log-Likelihood:               -396.226
Distribution:                  Normal   AIC:                           800.452
Method:            Maximum Likelihood   BIC:                           817.528
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:45   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu             0.0213  2.034e-02      1.045      0.296 [-1.860e-02,6.111e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      1.2528e-03  6.924e-04      1.809  7.041e-02 [-1.043e-04,2.610e-03]
alpha[1]   2.8289e-13  1.029e-02  2.750e-11      1.000 [-2.016e-02,2.016e-02]
beta[1]        0.9902  1.317e-02     75.170      0.000      [  0.964,  1.016]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting EGARCH(1,1) model...
                     Constant Mean - EGARCH Model Results                     
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                     EGARCH   Log-Likelihood:               -387.853
Distribution:                  Normal   AIC:                           783.705
Method:            Maximum Likelihood   BIC:                           800.782
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:46   Df Model:                            1
                                 Mean Model                                 
============================================================================
                 coef    std err          t      P>|t|      95.0% Conf. Int.
----------------------------------------------------------------------------
mu             0.0124  9.678e-09  1.281e+06      0.000 [1.239e-02,1.239e-02]
                                Volatility Model                               
===============================================================================
                  coef    std err          t      P>|t|        95.0% Conf. Int.
-------------------------------------------------------------------------------
omega      -6.1775e-03  2.369e-12 -2.607e+09      0.000 [-6.177e-03,-6.177e-03]
alpha[1]       -0.0427  5.392e-10 -7.921e+07      0.000 [-4.271e-02,-4.271e-02]
beta[1]         0.9983  8.692e-11  1.149e+10      0.000       [  0.998,  0.998]
===============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting TGARCH(1,1) model...
                   Constant Mean - GJR-GARCH Model Results                    
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                  GJR-GARCH   Log-Likelihood:               -395.415
Distribution:                  Normal   AIC:                           800.830
Method:            Maximum Likelihood   BIC:                           822.175
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:46   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu             0.0164  2.082e-02      0.790      0.430 [-2.437e-02,5.725e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      1.5388e-03  1.960e-03      0.785      0.432 [-2.303e-03,5.380e-03]
alpha[1]   2.6930e-18  5.383e-02  5.003e-17      1.000      [ -0.105,  0.105]
gamma[1]       0.0178  1.613e-02      1.101      0.271 [-1.386e-02,4.938e-02]
beta[1]        0.9799  6.011e-02     16.303  9.451e-60      [  0.862,  1.098]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting PGARCH(1,1) model...
                  Constant Mean - TARCH/ZARCH Model Results                   
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                TARCH/ZARCH   Log-Likelihood:               -401.060
Distribution:                  Normal   AIC:                           812.120
Method:            Maximum Likelihood   BIC:                           833.465
                                        No. Observations:                  528
Date:                Sat, Sep 07 2024   Df Residuals:                      527
Time:                        20:05:47   Df Model:                            1
                                  Mean Model                                 
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
mu         9.5323e-03  2.103e-02      0.453      0.650 [-3.168e-02,5.074e-02]
                               Volatility Model                              
=============================================================================
                 coef    std err          t      P>|t|       95.0% Conf. Int.
-----------------------------------------------------------------------------
omega      2.7098e-03  2.587e-03      1.047      0.295 [-2.361e-03,7.780e-03]
alpha[1]   1.2030e-12  3.498e-02  3.439e-11      1.000 [-6.856e-02,6.856e-02]
gamma[1]       0.0545  2.896e-02      1.880  6.005e-02   [-2.304e-03,  0.111]
beta[1]        0.9728  2.386e-02     40.763      0.000      [  0.926,  1.020]
=============================================================================

Covariance estimator: robust
No description has been provided for this image
Model Comparisons:
ARCH AIC: 929.63885887227, BIC: 942.4461477233888
GARCH AIC: 800.4518750673487, BIC: 817.5282602021738
EGARCH AIC: 783.7052696374003, BIC: 800.7816547722254
TGARCH AIC: 800.8297879626749, BIC: 822.1752693812062
PGARCH AIC: 812.1196711901466, BIC: 833.465152608678

Best model based on BIC: EGARCH

Comparing models based on volatility forecasting...
ARCH - Volatility Forecasting MSE: 1.1437886905815706
GARCH - Volatility Forecasting MSE: 1.0010917673953181
EGARCH - Volatility Forecasting MSE: 0.9842808459673964
TGARCH - Volatility Forecasting MSE: 0.9898297338822423
PGARCH - Volatility Forecasting MSE: 0.9995394824228735

Best model based on volatility forecasting (lowest mse): EGARCH

The results show that for USD/ZAR and GBP/USD, EGARCH was the best model based on both the Bayesian Information Criterion (BIC) and volatility forecasting. This suggests that these currency pairs exhibit strong asymmetric volatility, where negative shocks, such as bad news, have a greater impact on volatility than positive shocks, making EGARCH's ability to capture this leverage effect particularly effective for both model selection and volatility prediction. For AUD/USD, while EGARCH was the best model according to BIC, TGARCH performed better in volatility forecasting. This indicates that while EGARCH captured the overall volatility structure well, TGARCH's handling of threshold effects provided a better forecast of future volatility. This may reflect that in the AUD/USD market, negative shocks have a different but more subtle impact on volatility that TGARCH captures more effectively in short-term forecasting.

Question 2¶

In [ ]:
stock_tickers = ['TCS.NS', 'COALINDIA.NS', 'BAJFINANCE.NS']
stock_data = {ticker: yf.download(ticker, start=start_date, end=end_date) for ticker in stock_tickers}
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
[*********************100%%**********************]  1 of 1 completed
In [ ]:
for ticker, data in stock_data.items():
    print(f"Data for {ticker}")
    print(data.head())
Data for TCS.NS
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-08-30  3155.000000  3226.500000  3142.100098  3211.149902  3063.410156   
2022-09-01  3190.000000  3190.000000  3121.000000  3131.699951  2987.615967   
2022-09-02  3163.000000  3163.000000  3120.300049  3130.399902  2986.375732   
2022-09-05  3123.649902  3147.949951  3112.250000  3133.399902  2989.237793   
2022-09-06  3135.500000  3140.850098  3106.350098  3127.050049  2983.179932   

             Volume  
Date                 
2022-08-30  3431525  
2022-09-01  3546935  
2022-09-02  2052900  
2022-09-05  2147912  
2022-09-06  1936453  
Data for COALINDIA.NS
                  Open        High         Low       Close   Adj Close  \
Date                                                                     
2022-08-30  231.800003  235.500000  230.850006  234.800003  198.011673   
2022-09-01  234.350006  236.800003  229.550003  230.300003  194.216736   
2022-09-02  231.000000  232.449997  228.199997  229.300003  193.373413   
2022-09-05  230.000000  232.350006  228.500000  231.600006  195.313049   
2022-09-06  232.699997  234.649994  231.000000  232.699997  196.240707   

              Volume  
Date                  
2022-08-30  12991363  
2022-09-01   9682321  
2022-09-02   4599518  
2022-09-05   4909470  
2022-09-06   5307321  
Data for BAJFINANCE.NS
                   Open         High          Low        Close    Adj Close  \
Date                                                                          
2022-08-30  7000.000000  7335.000000  7000.000000  7306.250000  7238.995117   
2022-09-01  7228.600098  7333.850098  7142.000000  7181.299805  7115.194824   
2022-09-02  7217.100098  7313.000000  7173.450195  7190.350098  7124.162109   
2022-09-05  7190.700195  7254.000000  7158.000000  7196.200195  7129.958496   
2022-09-06  7228.750000  7255.000000  7105.000000  7119.350098  7053.815430   

             Volume  
Date                 
2022-08-30  1731381  
2022-09-01  1462579  
2022-09-02   906370  
2022-09-05   707025  
2022-09-06   791905  
In [ ]:
for stock_name, df in stock_data.items():
    returns = calculate_returns(df)
    evaluate_and_visualize_models(returns, stock_name)
**********************************************************Processing TCS.NS*****************************************************************
Fitting ARCH(1) model...
                      Constant Mean - ARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                       ARCH   Log-Likelihood:               -806.307
Distribution:                  Normal   AIC:                           1618.61
Method:            Maximum Likelihood   BIC:                           1631.24
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:02   Df Model:                            1
                                 Mean Model                                
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
mu             0.0795  5.588e-02      1.423      0.155 [-3.000e-02,  0.189]
                            Volatility Model                            
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
omega          1.4425      0.250      5.775  7.684e-09 [  0.953,  1.932]
alpha[1]       0.0429      0.162      0.264      0.792 [ -0.275,  0.361]
========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting GARCH(1,1) model...
                     Constant Mean - GARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                      GARCH   Log-Likelihood:               -806.047
Distribution:                  Normal   AIC:                           1620.09
Method:            Maximum Likelihood   BIC:                           1636.93
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:04   Df Model:                            1
                                 Mean Model                                
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
mu             0.0814  5.421e-02      1.502      0.133 [-2.484e-02,  0.188]
                            Volatility Model                            
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
omega          0.9842      0.348      2.831  4.639e-03 [  0.303,  1.666]
alpha[1]       0.0586      0.149      0.393      0.695 [ -0.234,  0.351]
beta[1]        0.2885      0.259      1.115      0.265 [ -0.219,  0.796]
========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting EGARCH(1,1) model...
                     Constant Mean - EGARCH Model Results                     
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                     EGARCH   Log-Likelihood:               -805.792
Distribution:                  Normal   AIC:                           1619.58
Method:            Maximum Likelihood   BIC:                           1636.42
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:05   Df Model:                            1
                                 Mean Model                                 
============================================================================
                 coef    std err          t      P>|t|      95.0% Conf. Int.
----------------------------------------------------------------------------
mu             0.0756  4.520e-03     16.729  8.061e-63 [6.675e-02,8.447e-02]
                             Volatility Model                             
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
omega          0.3340      0.130      2.571  1.013e-02 [7.940e-02,  0.589]
alpha[1]       0.1293      0.211      0.613      0.540   [ -0.284,  0.543]
beta[1]        0.1913      0.318      0.602      0.547   [ -0.432,  0.814]
==========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting TGARCH(1,1) model...
                   Constant Mean - GJR-GARCH Model Results                    
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                  GJR-GARCH   Log-Likelihood:               -805.305
Distribution:                  Normal   AIC:                           1620.61
Method:            Maximum Likelihood   BIC:                           1641.65
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:06   Df Model:                            1
                                 Mean Model                                
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
mu             0.0796  5.711e-02      1.393      0.163 [-3.235e-02,  0.191]
                            Volatility Model                            
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
omega          0.7106      2.816      0.252      0.801 [ -4.808,  6.229]
alpha[1]       0.0000      1.202      0.000      1.000 [ -2.357,  2.357]
gamma[1]       0.1027      0.565      0.182      0.856 [ -1.005,  1.211]
beta[1]        0.4819      2.790      0.173      0.863 [ -4.986,  5.950]
========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting PGARCH(1,1) model...
                  Constant Mean - TARCH/ZARCH Model Results                   
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                TARCH/ZARCH   Log-Likelihood:               -805.693
Distribution:                  Normal   AIC:                           1621.39
Method:            Maximum Likelihood   BIC:                           1642.43
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:06   Df Model:                            1
                                 Mean Model                                
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
mu             0.0772  5.479e-02      1.408      0.159 [-3.022e-02,  0.185]
                             Volatility Model                             
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
omega          1.1743      0.718      1.637      0.102   [ -0.232,  2.581]
alpha[1]       0.0802      0.102      0.784      0.433   [ -0.120,  0.281]
gamma[1]      -0.0481  5.002e-02     -0.962      0.336 [ -0.146,4.991e-02]
beta[1]        0.0000      0.569      0.000      1.000   [ -1.115,  1.115]
==========================================================================

Covariance estimator: robust
No description has been provided for this image
Model Comparisons:
ARCH AIC: 1618.614274825084, BIC: 1631.240044903374
GARCH AIC: 1620.09410527016, BIC: 1636.9284653745465
EGARCH AIC: 1619.5847850549112, BIC: 1636.4191451592976
TGARCH AIC: 1620.6102132194715, BIC: 1641.6531633499546
PGARCH AIC: 1621.3856440470065, BIC: 1642.4285941774897

Best model based on BIC: ARCH

Comparing models based on volatility forecasting...
ARCH - Volatility Forecasting MSE: 11.579840539839495
GARCH - Volatility Forecasting MSE: 11.594308901283053
EGARCH - Volatility Forecasting MSE: 11.559982619434779
TGARCH - Volatility Forecasting MSE: 11.557878604831322
PGARCH - Volatility Forecasting MSE: 11.559177030413606

Best model based on volatility forecasting (lowest mse): TGARCH

**********************************************************Processing COALINDIA.NS*****************************************************************
Fitting ARCH(1) model...
                      Constant Mean - ARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                       ARCH   Log-Likelihood:               -980.589
Distribution:                  Normal   AIC:                           1967.18
Method:            Maximum Likelihood   BIC:                           1979.80
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:07   Df Model:                            1
                                Mean Model                                
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
mu             0.1861  7.348e-02      2.533  1.130e-02 [4.212e-02,  0.330]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          2.4183      0.340      7.109  1.173e-12    [  1.752,  3.085]
alpha[1]       0.2848      0.157      1.816  6.938e-02 [-2.259e-02,  0.592]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting GARCH(1,1) model...
                     Constant Mean - GARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                      GARCH   Log-Likelihood:               -977.805
Distribution:                  Normal   AIC:                           1963.61
Method:            Maximum Likelihood   BIC:                           1980.44
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:07   Df Model:                            1
                                Mean Model                                
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
mu             0.1577  7.219e-02      2.184  2.894e-02 [1.620e-02,  0.299]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.8934      0.510      1.751  7.989e-02    [ -0.106,  1.893]
alpha[1]       0.2523      0.140      1.804  7.117e-02 [-2.175e-02,  0.526]
beta[1]        0.5070      0.187      2.707  6.782e-03    [  0.140,  0.874]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting EGARCH(1,1) model...
                     Constant Mean - EGARCH Model Results                     
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                     EGARCH   Log-Likelihood:               -975.827
Distribution:                  Normal   AIC:                           1959.65
Method:            Maximum Likelihood   BIC:                           1976.49
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:08   Df Model:                            1
                                Mean Model                                
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
mu             0.1578  6.968e-02      2.265  2.351e-02 [2.126e-02,  0.294]
                             Volatility Model                             
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
omega          0.2705      0.135      2.000  4.547e-02 [5.450e-03,  0.536]
alpha[1]       0.3948      0.160      2.469  1.355e-02 [8.138e-02,  0.708]
beta[1]        0.7876      0.101      7.779  7.319e-15   [  0.589,  0.986]
==========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting TGARCH(1,1) model...
                   Constant Mean - GJR-GARCH Model Results                    
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                  GJR-GARCH   Log-Likelihood:               -973.653
Distribution:                  Normal   AIC:                           1957.31
Method:            Maximum Likelihood   BIC:                           1978.35
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:08   Df Model:                            1
                                Mean Model                                
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
mu             0.1966  7.083e-02      2.776  5.510e-03 [5.777e-02,  0.335]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.7662      0.373      2.055  3.989e-02  [3.539e-02,  1.497]
alpha[1]       0.3326      0.187      1.775  7.583e-02 [-3.457e-02,  0.700]
gamma[1]      -0.2668      0.175     -1.528      0.126  [ -0.609,7.542e-02]
beta[1]        0.5805      0.155      3.738  1.858e-04    [  0.276,  0.885]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting PGARCH(1,1) model...
                  Constant Mean - TARCH/ZARCH Model Results                   
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                TARCH/ZARCH   Log-Likelihood:               -972.694
Distribution:                  Normal   AIC:                           1955.39
Method:            Maximum Likelihood   BIC:                           1976.43
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:09   Df Model:                            1
                                Mean Model                                
==========================================================================
                 coef    std err          t      P>|t|    95.0% Conf. Int.
--------------------------------------------------------------------------
mu             0.2099  7.676e-02      2.735  6.246e-03 [5.946e-02,  0.360]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.3375      0.190      1.779  7.531e-02 [-3.442e-02,  0.709]
alpha[1]       0.2638      0.128      2.068  3.860e-02  [1.384e-02,  0.514]
gamma[1]      -0.1509      0.111     -1.361      0.174  [ -0.368,6.645e-02]
beta[1]        0.6767      0.151      4.485  7.302e-06    [  0.381,  0.972]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Model Comparisons:
ARCH AIC: 1967.177122648522, BIC: 1979.802892726812
GARCH AIC: 1963.609092941013, BIC: 1980.4434530453993
EGARCH AIC: 1959.6536192708732, BIC: 1976.4879793752596
TGARCH AIC: 1957.3050204839146, BIC: 1978.3479706143978
PGARCH AIC: 1955.3878971832896, BIC: 1976.4308473137728

Best model based on BIC: PGARCH

Comparing models based on volatility forecasting...
ARCH - Volatility Forecasting MSE: 112.95719562081153
GARCH - Volatility Forecasting MSE: 114.66886125352477
EGARCH - Volatility Forecasting MSE: 111.24486967124801
TGARCH - Volatility Forecasting MSE: 110.93134570677911
PGARCH - Volatility Forecasting MSE: 109.8635533889916

Best model based on volatility forecasting (lowest mse): PGARCH

**********************************************************Processing BAJFINANCE.NS*****************************************************************
Fitting ARCH(1) model...
                      Constant Mean - ARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                       ARCH   Log-Likelihood:               -917.964
Distribution:                  Normal   AIC:                           1841.93
Method:            Maximum Likelihood   BIC:                           1854.55
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:09   Df Model:                            1
                               Mean Model                               
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
mu         6.5384e-03  6.820e-02  9.587e-02      0.924 [ -0.127,  0.140]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          2.1521      0.292      7.360  1.833e-13    [  1.579,  2.725]
alpha[1]       0.1016  9.375e-02      1.083      0.279 [-8.220e-02,  0.285]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting GARCH(1,1) model...
                     Constant Mean - GARCH Model Results                      
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                      GARCH   Log-Likelihood:               -917.736
Distribution:                  Normal   AIC:                           1843.47
Method:            Maximum Likelihood   BIC:                           1860.31
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:10   Df Model:                            1
                                Mean Model                               
=========================================================================
                  coef    std err          t      P>|t|  95.0% Conf. Int.
-------------------------------------------------------------------------
mu         -3.2361e-03  6.847e-02 -4.726e-02      0.962 [ -0.137,  0.131]
                            Volatility Model                            
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
omega          1.4130      1.435      0.984      0.325 [ -1.400,  4.226]
alpha[1]       0.0907      0.102      0.892      0.372 [ -0.108,  0.290]
beta[1]        0.3190      0.649      0.491      0.623 [ -0.954,  1.592]
========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting EGARCH(1,1) model...
                     Constant Mean - EGARCH Model Results                     
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                     EGARCH   Log-Likelihood:               -916.959
Distribution:                  Normal   AIC:                           1841.92
Method:            Maximum Likelihood   BIC:                           1858.75
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:11   Df Model:                            1
                               Mean Model                               
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
mu             0.0151  7.114e-02      0.213      0.831 [ -0.124,  0.155]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.3765      0.242      1.558      0.119 [-9.705e-02,  0.850]
alpha[1]       0.1850      0.113      1.636      0.102 [-3.658e-02,  0.407]
beta[1]        0.5758      0.277      2.075  3.795e-02  [3.201e-02,  1.119]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting TGARCH(1,1) model...
                   Constant Mean - GJR-GARCH Model Results                    
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                  GJR-GARCH   Log-Likelihood:               -916.589
Distribution:                  Normal   AIC:                           1843.18
Method:            Maximum Likelihood   BIC:                           1864.22
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:11   Df Model:                            1
                               Mean Model                               
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
mu         2.8055e-03  6.775e-02  4.141e-02      0.967 [ -0.130,  0.136]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          1.0436      0.548      1.905  5.683e-02 [-3.031e-02,  2.118]
alpha[1]       0.1625      0.132      1.228      0.220 [-9.696e-02,  0.422]
gamma[1]      -0.1385      0.149     -0.933      0.351    [ -0.430,  0.153]
beta[1]        0.4736      0.263      1.803  7.142e-02 [-4.129e-02,  0.989]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Fitting PGARCH(1,1) model...
                  Constant Mean - TARCH/ZARCH Model Results                   
==============================================================================
Dep. Variable:                Returns   R-squared:                       0.000
Mean Model:             Constant Mean   Adj. R-squared:                  0.000
Vol Model:                TARCH/ZARCH   Log-Likelihood:               -916.060
Distribution:                  Normal   AIC:                           1842.12
Method:            Maximum Likelihood   BIC:                           1863.16
                                        No. Observations:                  497
Date:                Sat, Sep 07 2024   Df Residuals:                      496
Time:                        20:10:12   Df Model:                            1
                               Mean Model                               
========================================================================
                 coef    std err          t      P>|t|  95.0% Conf. Int.
------------------------------------------------------------------------
mu             0.0248  7.243e-02      0.342      0.732 [ -0.117,  0.167]
                              Volatility Model                             
===========================================================================
                 coef    std err          t      P>|t|     95.0% Conf. Int.
---------------------------------------------------------------------------
omega          0.5995      0.295      2.034  4.195e-02  [2.182e-02,  1.177]
alpha[1]       0.1323  8.629e-02      1.533      0.125 [-3.680e-02,  0.301]
gamma[1]      -0.0643  9.608e-02     -0.670      0.503    [ -0.253,  0.124]
beta[1]        0.5379      0.223      2.410  1.596e-02    [  0.100,  0.975]
===========================================================================

Covariance estimator: robust
No description has been provided for this image
Model Comparisons:
ARCH AIC: 1841.9278396797808, BIC: 1854.5536097580707
GARCH AIC: 1843.4723447869778, BIC: 1860.3067048913642
EGARCH AIC: 1841.917238364929, BIC: 1858.7515984693155
TGARCH AIC: 1843.1787132736674, BIC: 1864.2216634041506
PGARCH AIC: 1842.120045353808, BIC: 1863.1629954842913

Best model based on BIC: ARCH

Comparing models based on volatility forecasting...
ARCH - Volatility Forecasting MSE: 32.0599508425907
GARCH - Volatility Forecasting MSE: 32.02554627106747
EGARCH - Volatility Forecasting MSE: 31.92403591329105
TGARCH - Volatility Forecasting MSE: 32.222930254099964
PGARCH - Volatility Forecasting MSE: 31.89102989564405

Best model based on volatility forecasting (lowest mse): PGARCH

The results indicate that different models perform best depending on the evaluation metric (BIC or volatility forecast) for each stock. For Bajaj Finance, while the ARCH model had the lowest BIC, indicating it fits the data well, PGARCH provided the best volatility forecast, suggesting it captures more nuances in volatility dynamics over time. In the case of Coal India, PGARCH was the best model both in terms of BIC and volatility forecasting, meaning it not only fits the data well but also excels at predicting future volatility. Finally, for TCS, the ARCH model had the lowest BIC, suggesting it offers a simpler, better-fitting model, but TGARCH produced better volatility forecasts, likely because TCS exhibits asymmetric volatility patterns that TGARCH is better equipped to capture.